LEADTOOLS Image File Support (Leadtools.Codecs assembly)

EncodeAbic(Byte[],Int32,Int32,Int32,Boolean) Method

Show in webframe
Example 







A byte array which contains the input data.
Number of bytes aligned for uncompressed input data.
Image width, in pixels.
Image height, in pixels.
true to indicate bi-level encoding, false to indicate 4-bit grayscale encoding.
Encodes the input raw data using the ABIC encoder.
Syntax
public byte[] EncodeAbic( 
   byte[] inputData,
   int align,
   int width,
   int height,
   bool biLevel
)
'Declaration
 
Public Overloads Function EncodeAbic( _
   ByVal inputData() As Byte, _
   ByVal align As Integer, _
   ByVal width As Integer, _
   ByVal height As Integer, _
   ByVal biLevel As Boolean _
) As Byte()
'Usage
 
Dim instance As RasterCodecs
Dim inputData() As Byte
Dim align As Integer
Dim width As Integer
Dim height As Integer
Dim biLevel As Boolean
Dim value() As Byte
 
value = instance.EncodeAbic(inputData, align, width, height, biLevel)
public byte[] EncodeAbic( 
   byte[] inputData,
   int align,
   int width,
   int height,
   bool biLevel
)

            
public byte[] encodeAbic(byte[] inputData, int align, int width, int height, boolean biLevel)
 function Leadtools.Codecs.RasterCodecs.EncodeAbic(Byte[],Int32,Int32,Int32,Boolean)( 
   inputData ,
   align ,
   width ,
   height ,
   biLevel 
)
public:
array<byte>^ EncodeAbic( 
   array<byte>^ inputData,
   int align,
   int width,
   int height,
   bool biLevel
) 

Parameters

inputData
A byte array which contains the input data.
align
Number of bytes aligned for uncompressed input data.
width
Image width, in pixels.
height
Image height, in pixels.
biLevel
true to indicate bi-level encoding, false to indicate 4-bit grayscale encoding.

Return Value

A byte array that contains the ABIC encoded data.
Remarks

Call this method to compress the input raw data to 1-bit bi-level or 4-bit grayscale ABIC data.

Use DecodeAbic(Byte[],Int32,Int32,Int32,Boolean) to decode ABIC data.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing

Public Sub EncodeDecodeAbicExample()
   Dim codecs As RasterCodecs = New RasterCodecs()

   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
   Dim destDataFile As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Abic.bmp")

   ' Load the file save it to a memory stream as RAW
   Console.WriteLine("Loading the source image as 1 bits/pixel")
   Dim srcImage As RasterImage = codecs.Load(srcFileName, 1, CodecsLoadByteOrder.Rgb, 1, 1)

   Console.WriteLine("Saving the image to memory as RAW format")
   Dim ms As MemoryStream = New MemoryStream()
   codecs.Save(srcImage, ms, RasterImageFormat.Raw, srcImage.BitsPerPixel)

   Console.WriteLine("Encoding the data as ABIC")
   Dim rawData As Byte() = ms.GetBuffer()
   ms.Close()

   ' Encode this data as ABIC
   Dim abicData As Byte() = codecs.EncodeAbic(rawData, 4, srcImage.Width, srcImage.Height, False)

   ' Decode the data back to RAW
   Console.WriteLine("Deconding the data back as RAW")
   rawData = codecs.DecodeAbic(abicData, 4, srcImage.Width, srcImage.Height, False)

   ' Create a new image from this data
   Dim destImage As RasterImage = New RasterImage(RasterMemoryFlags.Conventional, srcImage.Width, srcImage.Height, srcImage.BitsPerPixel, srcImage.Order, srcImage.ViewPerspective, srcImage.GetPalette(), IntPtr.Zero, 0)

   ' Add the scan lines
   Dim y As Integer = 0
   Do While y < destImage.Height
      Dim bufferIndex As Integer = y * destImage.BytesPerLine
      destImage.SetRow(y, rawData, bufferIndex, destImage.BytesPerLine)
      y += 1
   Loop

   ' Save this image to disk
   codecs.Save(destImage, destDataFile, RasterImageFormat.Bmp, destImage.BitsPerPixel)

   srcImage.Dispose()
   destImage.Dispose()

   ' Clean up
   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

public void EncodeDecodeAbicExample()
{
   RasterCodecs codecs = new RasterCodecs();

   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
   string destDataFile = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Abic.bmp");

   // Load the file save it to a memory stream as RAW
   Console.WriteLine("Loading the source image as 1 bits/pixel");
   RasterImage srcImage = codecs.Load(srcFileName, 1, CodecsLoadByteOrder.Rgb, 1, 1);

   Console.WriteLine("Saving the image to memory as RAW format");
   MemoryStream ms = new MemoryStream();
   codecs.Save(srcImage, ms, RasterImageFormat.Raw, srcImage.BitsPerPixel);

   Console.WriteLine("Encoding the data as ABIC");
   byte[] rawData = ms.GetBuffer();
   ms.Close();

   // Encode this data as ABIC
   byte[] abicData = codecs.EncodeAbic(rawData, 4, srcImage.Width, srcImage.Height, false);

   // Decode the data back to RAW
   Console.WriteLine("Deconding the data back as RAW");
   rawData = codecs.DecodeAbic(abicData, 4, srcImage.Width, srcImage.Height, false);

   // Create a new image from this data
   RasterImage destImage = new RasterImage(
      RasterMemoryFlags.Conventional,
      srcImage.Width,
      srcImage.Height,
      srcImage.BitsPerPixel,
      srcImage.Order,
      srcImage.ViewPerspective,
      srcImage.GetPalette(),
      IntPtr.Zero,
      0);

   // Add the scan lines
   for (int y = 0; y < destImage.Height; y++)
   {
      int bufferIndex = y * destImage.BytesPerLine;
      destImage.SetRow(y, rawData, bufferIndex, destImage.BytesPerLine);
   }

   // Save this image to disk
   codecs.Save(destImage, destDataFile, RasterImageFormat.Bmp, destImage.BitsPerPixel);

   srcImage.Dispose();
   destImage.Dispose();

   // Clean up
   codecs.Dispose();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.